/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import entity.tta.OutletDataModel;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;

/**
 *
 * @author Chen Zhe, Lu Xiaodi
 */
@Entity
public class Outlet implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id; 
    private String outletName;
    private String address;
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Calendar createTime;
    @ManyToOne(cascade = {CascadeType.PERSIST})
    private StakeholderFood stakeholder;
    private String phoneNumber;
    @OneToOne(cascade = {CascadeType.ALL})
    private OutletManager manager;
    private List<Integer> openingHours = new ArrayList<Integer>();
    private List< Integer> closingHours = new ArrayList<Integer>();
    @ManyToMany(cascade = {CascadeType.PERSIST})
    private List<Cuisine> cuisines = new ArrayList<Cuisine>();
    @OneToMany(cascade = {CascadeType.PERSIST})
    private List<OutletSeatArea> seatingAreas = new ArrayList<OutletSeatArea>();
    @OneToMany(cascade = {CascadeType.ALL})
    private List<FoodItem> foodMenu = new ArrayList<FoodItem>();
    @OneToMany(cascade = {CascadeType.ALL}, mappedBy = "outlet")
    private List<OutletReservation> reservations = new ArrayList<OutletReservation>();
    private Double noShowPenalty;
    private Boolean autoConfirmReservation;
    private Integer bookingWindow;
    private Integer leadTime_Day;
    private String pathName;
    @OneToOne(cascade = {CascadeType.ALL})
    private OutletDataModel outletDataModel;


    public Outlet() {
    }

    public void create(String outletName, String phoneNumber, StakeholderFood stakeholder, OutletManager manager, String address) {
        this.outletName = outletName;
        this.phoneNumber = phoneNumber;
        this.stakeholder = stakeholder;
        this.manager = manager;
        this.address = address;
    }

    public void create(String outletName) {
        this.outletName = outletName;
    }

    public void addArea(OutletSeatArea area) {
        seatingAreas.add(area);
    }

    public void removeArea(OutletSeatArea area) {
        final Long id = area.getId();
        if (seatingAreas.contains(area)) {
            seatingAreas.remove(area);
        }
    }

    //getter and setters
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public StakeholderFood getStakeholder() {
        return stakeholder;
    }

    public void setStakeholder(StakeholderFood stakeholder) {
        this.stakeholder = stakeholder;
    }

    public String getOutletName() {
        return outletName;
    }

    public void setOutletName(String outletName) {
        this.outletName = outletName;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public List<Integer> getOpeningHours() {
        return openingHours;
    }

    public void setOpeningHours(List<Integer> openingHours) {
        this.openingHours = openingHours;
    }

    public List< Integer> getClosingHours() {
        return closingHours;
    }

    public void setClosingHours(List< Integer> closingHours) {
        this.closingHours = closingHours;
    }

    public List<Cuisine> getCuisines() {
        return cuisines;
    }

    public void setCuisines(List<Cuisine> cuisines) {
        this.cuisines = cuisines;
    }

    public List<OutletSeatArea> getSeatingAreas() {
        return seatingAreas;
    }

    public void setSeatingAreas(List<OutletSeatArea> seatingAreas) {
        this.seatingAreas = seatingAreas;
    }

    public List<OutletReservation> getReservations() {
        return reservations;
    }

    public void setReservations(List<OutletReservation> unconfirmedReservations) {
        this.reservations = unconfirmedReservations;
    }

    public void addReservations(OutletReservation r) {
        this.reservations.add(r);
    }

    public Boolean getAutoConfirmReservation() {
        return autoConfirmReservation;
    }

    public void setAutoConfirmReservation(Boolean autoConfirmReservation) {
        this.autoConfirmReservation = autoConfirmReservation;
    }

    public Integer getBookingWindow() {
        return bookingWindow;
    }

    public void setBookingWindow(Integer bookingWindow) {
        this.bookingWindow = bookingWindow;
    }

    public Integer getLeadTime_Day() {
        return leadTime_Day;
    }

    public void setLeadTime_Day(Integer leadTime_Day) {
        this.leadTime_Day = leadTime_Day;
    }

    public Double getNoShowPenalty() {
        return noShowPenalty;
    }

    public void setNoShowPenalty(Double noShowPenalty) {
        this.noShowPenalty = noShowPenalty;
    }

    public OutletManager getManager() {
        return manager;
    }

    public void setManager(OutletManager manager) {
        this.manager = manager;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public void addFoodItem(FoodItem f) {
        this.foodMenu.add(f);
    }

    public List<FoodItem> getFoodMenu() {
        return foodMenu;
    }

    public void setFoodMenu(List<FoodItem> foodMenu) {
        this.foodMenu = foodMenu;
    }

    public void removeFoodItem(FoodItem item) {
        this.foodMenu.remove(item);
    }

    public String getPathName() {
        return pathName;
    }

    public void setPathName(String pathName) {
        this.pathName = pathName;
    }

    public OutletDataModel getOutletDataModel() {
        return outletDataModel;
    }

    public void setOutletDataModel(OutletDataModel outletDataModel) {
        this.outletDataModel = outletDataModel;
    }

    public Calendar getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Calendar createTime) {
        this.createTime = createTime;
    }
}
